using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SystRestrClient;
using BU.NetgestClient;

namespace OpenEPNClient
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "Admn" & textBox2.Text == "test")
            {
                this.Hide();
            }
            else
            {
                TcpClientCommand monmodele = new TcpClientCommand(9000, "172.22.0.10");
                monmodele.vaffich += new Ecrirearea(majtextarea);//(majtextarea);
                monmodele.vconnex = new TCPClientConnexion("L'affreuse", "Lulu", "azerty");
                monmodele.connect();
                if (!monmodele.tconnect)
                {
                    MessageBox.Show("pas connecte");
                    return;
                }
                if (!monmodele.ClientSocket.Connected)
                    MessageBox.Show("pas connecte");
                else
                {
                    monmodele.SendMsg(textBox1.Text);//+ " " + textBox2.Text );

                    this.Hide();
                }
            }
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            SystRestrClient.RestrictTaslMgr.KillTaskMgr();
            RestrictKeys restrictionClavier = new RestrictKeys();
            restrictionClavier.chargement();
        }

        private void majtextarea(string v)
        {
            //if (this.richTextBox1.InvokeRequired)
            //{
            //    Callback d = new Callback(majtextarea);
            //    this.Invoke(d, new object[] { v });
            //}
            //else
            //{
            //    richTextBox1.AppendText(v + "\r\n");
            //    richTextBox1.ScrollToCaret();
            //}
            MessageBox.Show("Yes");
        } 
    }
}